// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
const db = cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {
  try{
    return await db.collection('heafood').add({
        data:{
          mealCalories:event.addMeal.mealCal,
          mealcb:event.addMeal.mealCb,
          mealcou:event.addMeal.mealCou,
          mealfat:event.addMeal.mealFat,
          mealimg:event.addMeal.modalImageList[0],
          mealingredient:event.addMeal.mealIng,
          mealname:event.addMeal.mealName,
          mealprotein:event.addMeal.mealProtein,
          type:event.addMeal.type,
          nowIndex:event.addMeal.nowIndex
        },
        success:res=>{
         console.log(res)
        },
        fail:err=>{
            console.error(err)
        }
    })
}catch(e){
    console.log(e)
}
}